package com.atguigu.tingshu.album.api;

import com.atguigu.tingshu.album.service.AlbumInfoService;
import com.atguigu.tingshu.album.service.BaseCategoryService;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.album.AlbumAttributeValue;
import com.atguigu.tingshu.model.album.BaseAttribute;
import com.atguigu.tingshu.model.album.BaseCategory3;
import com.atguigu.tingshu.vo.category.CategoryVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.simpleframework.xml.Path;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Tag(name = "分类管理")
@RestController
@RequestMapping(value="/api/album/category")
@SuppressWarnings({"unchecked", "rawtypes"})
public class BaseCategoryApiController {
	
	@Autowired
	private BaseCategoryService baseCategoryService;

	@Autowired
	private AlbumInfoService albumInfoService;

	//Request URL: http://localhost:8500/api/album/category/getBaseCategoryList
	@GetMapping("/getBaseCategoryList")
	@Operation(summary = "获取三级分类集合")
	public Result getBaseCategoryList(){
		List<CategoryVo> categoryVoList = baseCategoryService.getBaseCategoryList();
		return Result.ok(categoryVoList);
	}

	//Request URL: http://localhost:8500/api/album/category/findAttribute/1
	@GetMapping("/findAttribute/{category1Id}")
	@Operation(summary = "获取该分类标签id下的属性值")
	public Result findAttributeAndValue(@PathVariable Long category1Id){
		 List<BaseAttribute> baseAttribute = baseCategoryService.findAttributeAndValue(category1Id);
		 return Result.ok(baseAttribute);
	}

	//Request URL: http://localhost:8500/api/album/category/findTopBaseCategory3/1
	@GetMapping("/findTopBaseCategory3/{category1Id}")
	@Operation(summary = "获取一级分类下的top7专辑")
	public Result<List<BaseCategory3>> getTop7Category3ByCategory1Id(@PathVariable(value = "category1Id") Long category1Id){
		List<BaseCategory3> list = albumInfoService.getTop7Category3ByCategory1Id(category1Id);
		return Result.ok(list);
	}

	//Request URL: http://localhost:8500/api/album/category/getBaseCategoryList/1
	@GetMapping("/getBaseCategoryList/{category1Id}")
	@Operation(summary = "获取指定一级分类下的所有分类数据集合")
	public Result getBaseCategoryList(@PathVariable Long category1Id){
		CategoryVo categoryVoList = baseCategoryService.getBaseCategoryList(category1Id);
		return Result.ok(categoryVoList);
	}

}

